import http from '@/utils/http';
import type { TAddNewReq, TContent, TImage, TUpdateContent } from './type';

/** 新增 */
export const addNewContent = (data: TAddNewReq) =>
  http.post<number>('/api/v1/draft/create', data);

/** 查询所有 */
export const findAllList = () => http.get<TContent[]>('/api/v1/draft/all');

/** 获取详情 */
export const findDetail = (id: number) =>
  http.get<TContent>(`/api/v1/draft/detail?id=${id}`);

/** 更新 */
export const updateContent = (data: TUpdateContent) =>
  http.post<number>('/api/v1/draft/update', data);

/** 删除 */
export const delContent = (id: number) =>
  http.get<number>(`/api/v1/draft/delete?id=${id}`);

/** 获取所有图片 */
export const findAllImage = (id: number) =>
  http.get<TImage[]>(`/api/v1/draft/allImage?id=${id}`);
